/*
 * Copyright (c) 2009 by unreserved.org.
 * All rights reserved.
 */

package org.unreserved.ladderplot;

import org.apache.log4j.Logger;

public class Player implements HAnchor {
    private static final Logger logger = Logger.getLogger(Player.class);
    
    /** Index of next player to be created. */
    //private static int nextIndex = 0;
    
    protected String name;
    protected String nickname;
    //protected int index = nextIndex++;
    protected int column = -1;
    /*
     * Expected to be single character. Is String just to ease writing
     * to TextLine.
     */
    protected String lineString = "|";
    
    public Player(String name, String nickname) {
        this.name = name;
        this.nickname = nickname;
        //this.index = index;
    }
    
    public String getName() {
        return name;
    }
    
    public String getNickname() {
        return nickname;
    }
    
    //public int getIndex() {
    //    return index;
    //}
    
    public void setColumn(int column) {
        logger.debug("setColumn " + nickname + ": " + column);
        this.column = column;
    }
    
    public int getColumn() {
        return column;
    }
    
    public void setLineChar(String lineString) {
        if (lineString == null || lineString.length() != 1) {
            throw new IllegalArgumentException("[" + lineString + "]");
        }
        this.lineString = lineString;
    }
    
    public String getLineChar() {
        return lineString;
    }
    
    // from HAnchor interface
    public int getStart() {
        return column;
    }
    
    // from HAnchor interface
    public int getWidth() {
        return 1;
    }
    
    public String toString() {
        return "Player[" + name + "," + nickname + /*"," + index +*/ "]";
    }
}
